package com.wzapp.sitposture.usercenter.entity;

import com.alibaba.fastjson.JSONObject;
import com.wzapp.sitposture.common.converter.DateConverterJson;
import com.wzapp.sitposture.common.converter.JsonObjectConverterJson;
import com.wzapp.sitposture.common.converter.DefaultDateConverterJson;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by qianglong on 2018/3/25.
 */
@Data
@Entity(name = "user_login_log")
public class UserLoginLog implements Serializable {

    private static final long serialVersionUID = -1362519396788288296L;

    @Id
    @GeneratedValue(generator = "uuid_32")
    @GenericGenerator(name = "uuid_32", strategy = "uuid")
    @Column(length = 32)
    private String id;

    /**
     * 用户ID
     */
    private String userId;
    /**
     * 登录终端 APP-APP端,PC-PC端,H5-H5
     */
    private String terminalType;
    /**
     * IP地址
     */
    private String requestIp;
    /**
     * 登录时间，毫秒
     */
    @Convert(converter = DefaultDateConverterJson.class)
    private Long loginTime;
    /**
     * 登出时间，毫秒
     */
    @Convert(converter = DefaultDateConverterJson.class)
    private Long logoutTime;
    /**
     * 登录时长，毫秒
     */
    private Long loginDuration;
    /**
     * 创建时间，毫秒
     */
    @Convert(converter = DateConverterJson.class)
    private Long createTime;
    /**
     * 更新时间，毫秒
     */
    @Convert(converter = DateConverterJson.class)
    private Long updateTime;
    /**
     * 设备信息
     */
    @Column(name = "device_info", nullable = true, columnDefinition = "text")
    @Convert(converter = JsonObjectConverterJson.class)
    private JSONObject deviceInfo;
    /**
     * 城市id
     */
    private String cityId;
    /**
     * 城市名称 格式为：省份.城市
     */
    private String cityName;
    /**
     * 登录系统 ：IOS，Android,pc
     */
    private String clientApplication;
}
